Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
@nuxtjs/proxy
Advanced tools
The one-liner node.js http-proxy middleware solution for Nuxt.js using http-proxy-middleware
@nuxtjs/proxy is a Nuxt.js module that allows you to easily configure proxy middleware for your Nuxt.js application. This is particularly useful for handling API requests during development, avoiding CORS issues, and routing requests to different backends.
Basic Proxy Setup
This feature allows you to set up a basic proxy configuration. In this example, any request to `/api/` will be proxied to `http://api.example.com`, and the `/api/` prefix will be removed from the request path.
json
{
"modules": [
"@nuxtjs/proxy"
],
"proxy": {
"/api/": {
"target": "http://api.example.com",
"pathRewrite": { "^/api/": "" }
}
}
}
Multiple Proxies
This feature allows you to set up multiple proxy configurations. In this example, requests to `/api/` are proxied to `http://api.example.com`, and requests to `/auth/` are proxied to `http://auth.example.com`.
json
{
"modules": [
"@nuxtjs/proxy"
],
"proxy": {
"/api/": {
"target": "http://api.example.com",
"pathRewrite": { "^/api/": "" }
},
"/auth/": {
"target": "http://auth.example.com",
"pathRewrite": { "^/auth/": "" }
}
}
}
Custom Proxy Options
This feature allows you to customize proxy options. In this example, `changeOrigin` is set to `true` to change the origin of the host header to the target URL, and `secure` is set to `false` to allow self-signed SSL certificates.
json
{
"modules": [
"@nuxtjs/proxy"
],
"proxy": {
"/api/": {
"target": "http://api.example.com",
"pathRewrite": { "^/api/": "" },
"changeOrigin": true,
"secure": false
}
}
}
http-proxy-middleware is a popular Node.js package for creating proxy middleware. It offers a wide range of customization options and can be used with various frameworks like Express, Koa, and more. Compared to @nuxtjs/proxy, it requires more manual setup but offers greater flexibility.
axios is a promise-based HTTP client for the browser and Node.js. While it is not a proxy middleware, it can be used in conjunction with proxy settings to handle API requests. It is more focused on making HTTP requests rather than setting up proxies, but it can be configured to work with proxy servers.
node-http-proxy is a full-featured HTTP proxy for Node.js. It provides a robust set of features for creating proxy servers and routing HTTP requests. It is more low-level compared to @nuxtjs/proxy and requires more configuration, but it offers extensive customization options.
The one-liner node.js http-proxy middleware solution for Nuxt.js using http-proxy-middleware
✨ Do you know that Axios Module has built in support for Proxy Module?
✓ Path rewrites
✓ Host based router (useful for staging/test)
✓ Logs / Proxy Events
✓ WebSockets
✓ Auth / Cookie
✓ ...and more! (see http-proxy-middleware docs)
⚠ Does not work in generated/static mode!
@nuxtjs/proxy
dependency with yarn
or npm
to your project@nuxtjs/proxy
to the modules
section of nuxt.config.js
{
modules: [
// Simple usage
'@nuxtjs/proxy',
// With options
['@nuxtjs/proxy', { pathRewrite: { '^/api' : '/api/v1' } }]
]
}
proxy
section of nuxt.config.js
(See proxy section below)changeOrigin
and ws
options are enabled by default.[optional] You can provide default options to all proxy targets by passing options to module options.
proxy
You can provide proxy config using either object or array.
You can use magic shorthands
{
proxy: [
// Proxies /foo to http://example.com/foo
'http://example.com/foo',
// Proxies /api/books/*/**.json to http://example.com:8000
'http://example.com:8000/api/books/*/**.json',
// You can also pass more options
[ 'http://example.com/foo', { ws: false } ]
]
}
Keys are context
{
proxy: {
// Simple proxy
'/api': 'http://example.com',
// With options
'/api2': { target: 'http://example.com', ws: false }
}
}
yarn install
or npm install
npm run dev
Copyright (c) Nuxt Community - Pooya Parsa pooya@pi0.ir
FAQs
proxy support for nuxt server
The npm package @nuxtjs/proxy receives a total of 125,984 weekly downloads. As such, @nuxtjs/proxy popularity was classified as popular.
We found that @nuxtjs/proxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.